package de.medizin.uni.halle.irm;


import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.Window;

public class IntroScreenActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	super.onCreate(savedInstanceState);
	setContentView(R.layout.intro);
	/** set time to splash out */
	final int welcomeScreenDisplay = 1000;
	/** create a thread to show splash up to splash time */

	Thread welcomeThread = new Thread() {
	
			int wait = 0;
			
			@Override
			public void run() {
				try {
					super.run();
			    	SQLiteDatabase database = openOrCreateDatabase("born", Context.MODE_PRIVATE, null);        
			        new ExampleData(database);
			        database.close();
					/**
					* use while to get the splash time. Use sleep() to increase
					* the wait variable for every 100L.
					*/
					while (wait < welcomeScreenDisplay) {
						sleep(100);
						wait += 100;
					}
				} catch (Exception e) {
					System.out.println("EXc=" + e);
					} finally {
					/**
					* Called after splash times up. Do some action after splash
					* times up. Here we moved to another main activity class
					*/
					startActivity(new Intent(IntroScreenActivity.this,
					BornActivity.class));
					finish();
				}
			}
		};
		welcomeThread.start();
	
	}
}